🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / testing / src / commonMain / kotlin / org / meshtastic / core / testing / BaseFake.kt
Displaying Raw • Download
core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/BaseFake.kt 41414f832f938b655c97bc07509bc140ea16e2a3 (41414f83) Text, 1.97 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.testing
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableSharedFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableStateFlow
T8b949e/** Base class for fakes that provides common utilities for state management and reset capabilities. */
Tff7b72abstract Tff7b72class T56d364BaseFake Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3resetActions Tff7b72= Te6edf3mutableListOfTff7b72<Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTff7b72>Tb4b4b4(Tb4b4b4)
T8b949e/** Creates a [MutableStateFlow] and registers it for automatic reset. */
Tff7b72protected Tff7b72fun Tff7b72<Te6edf3TTff7b72> Td2a8ffmutableStateFlowTb4b4b4(Te6edf3initialValueTb4b4b4: Te6edf3TTb4b4b4)Tb4b4b4: Te6edf3MutableStateFlowTff7b72<Te6edf3TTff7b72> Tb4b4b4{
Tff7b72val Te6edf3flow Tff7b72= Te6edf3MutableStateFlowTb4b4b4(Te6edf3initialValueTb4b4b4)
Te6edf3resetActionsTb4b4b4.Te6edf3add Tb4b4b4{ Te6edf3flowTb4b4b4.Te6edf3value Tff7b72= Te6edf3initialValue Tb4b4b4}
Tff7b72return Te6edf3flow
Tb4b4b4}
T8b949e/** Creates a [MutableSharedFlow] and registers it for automatic reset (replay cache cleared). */
Tff7b72protected Tff7b72fun Tff7b72<Te6edf3TTff7b72> Td2a8ffmutableSharedFlowTb4b4b4(Te6edf3replayTb4b4b4: Tffa657Int Tff7b72= T79c0ff0Tb4b4b4)Tb4b4b4: Te6edf3MutableSharedFlowTff7b72<Te6edf3TTff7b72> Tb4b4b4{
Tff7b72val Te6edf3flow Tff7b72= Te6edf3MutableSharedFlowTff7b72<Te6edf3TTff7b72>Tb4b4b4(Te6edf3replay Tff7b72= Te6edf3replayTb4b4b4)
Te6edf3resetActionsTb4b4b4.Te6edf3add Tb4b4b4{ Te6edf3flowTb4b4b4.Te6edf3resetReplayCacheTb4b4b4(Tb4b4b4) Tb4b4b4}
Tff7b72return Te6edf3flow
Tb4b4b4}
T8b949e/** Registers a custom reset action (e.g. clearing a list of recorded calls). */
Tff7b72protected Tff7b72fun Td2a8ffregisterResetActionTb4b4b4(Te6edf3actionTb4b4b4: Tb4b4b4(Tb4b4b4) Tff7b72-Tff7b72> Tffa657UnitTb4b4b4) Tb4b4b4{
Te6edf3resetActionsTb4b4b4.Te6edf3addTb4b4b4(Te6edf3actionTb4b4b4)
Tb4b4b4}
T8b949e/** Resets all registered state flows and custom actions to their initial state. */
Tff7b72open Tff7b72fun Td2a8ffresetTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3resetActionsTb4b4b4.Te6edf3forEach Tb4b4b4{ Tffa657itTb4b4b4(Tb4b4b4) Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s